﻿<html>
<head>
    <title></title>
    <script src="jsdb.js" type="text/javascript"></script>
    <script src="test.js" type="text/javascript"></script>
</head>
<body>
    <div id="outdiv">
    </div>
    <script type="text/javascript">
        var record = 100000;
        var repeat = 20;

        var t = new gonzales();
        t.div = document.getElementById("outdiv");

        t.addFunction("create_collection", function () {
            $db.create.collection("persone");
        }, 1);

        $db.sortType = 0;
        $db.objectByRef = false;

        t.addFunction("insert_into", function () {
            for (var x = 0; x < record; x++)
                $db.insert().into("persone").value({ "nome": "mario" + Math.round(Math.random() * 10), "peso": Math.round(Math.random() * 100) });
        }, 1);

        //t.start(); return;

        t.div = document.getElementById("outdiv");

        t.addFunction("select.from", function () {
            $db.select().from("persone").execute();
        }, repeat, null);

        t.addFunction("select.top.from", function () {
            $db.select().top(Math.floor(record * 0.5)).from("persone").execute();
        }, repeat, null);

        t.addFunction("select.from.orderby", function () {
            $db.select().from("persone").orderby("peso", "nome").execute();
        }, repeat, null);

        t.addFunction("select.top.from.orderby", function () {
            $db.select().top(Math.floor(record * 0.1)).from("persone").orderby("peso", "nome").execute();
        }, repeat, null);

        t.addFunction("select.from.orderby.desc", function () {
            $db.select().from("persone").orderby("peso", "nome").desc().execute();
        }, repeat, null);

        t.addFunction("select.top.from.orderby.desc", function () {
            $db.select().top(Math.floor(record * 0.1)).from("persone").orderby("peso", "nome").desc().execute();
        }, repeat, null);

        t.addFunction("count.from", function () {
            $db.count().from("persone").execute();
        }, repeat, null);

        t.addFunction("select.from.where greaterthan", function () {
            $db.select().from("persone").where($db.op.greaterthan("peso", 50)).execute();
        }, repeat, null);

        t.addFunction("select.from.where greaterthan.orderby", function () {
            $db.select().from("persone").where($db.op.greaterthan("peso", 50)).orderby("peso", "nome").execute();
        }, repeat, null);

        t.addFunction("count.from.where greaterthan", function () {
            $db.count().from("persone").where($db.op.greaterthan("peso", 50)).execute();
        }, repeat, null);

        t.addFunction("count.from.where greaterthan.orderby", function () {
            $db.count().from("persone").where($db.op.greaterthan("peso", 50)).orderby("peso", "nome").execute();
        }, repeat, null);

        t.addFunction("del.from.where", function () {
            $db.del().from("persone").where($db.op.greaterthan("peso", 50)).execute()
        }, repeat, prep);




        t.start();

        var prep = function () {
            $db.deletecollection(collection);
            $db.create.collection("persone");
            for (var x = 0; x < record; x++)
                $db.insert.into("persone").value({ "nome": "mario" + Math.round(Math.random() * 10), "peso": Math.round(Math.random() * 100) });
        };

        var noop = function () { };

        
    </script>
</body>
</html>
